using System.Reflection;
using ECommerce.Web.FetchingStrategies;
using ECommerce.Web.Models;
using FluentValidation;
using StructureMap.Configuration.DSL;

namespace ECommerce.Web
{
    public class ECommerceRegistry : Registry
    {
        public ECommerceRegistry()
        {
            var assembly = Assembly.Load("ECommerce.Web");

            For<IFetchingStrategy<IShopperWithBasket>>().Singleton().Use<ShopperWithBasketFetchingStrategy>();

            AssemblyScanner.FindValidatorsInAssembly(assembly).ForEach(x => For(x.InterfaceType).Singleton().Use(x.ValidatorType));

            Scan(x =>
                {
                    x.Assembly(assembly);
                    x.WithDefaultConventions();
                });
        }
    }
}